

function $(selector){
	return document.querySelectorAll(selector);
}

var nav_item = $(".header-nav .nav-item"),
    hNavMenu = $(".header-nav-menu")[0],
    cateItem = $(".category-item");

/**导航栏弹出下拉**/
function headerNavMenu(){
	for(var i = 0;i<nav_item.length-2;i++){
		(function(i){
			nav_item[i].onmouseover = function(){
				hNavMenu.classList.add("header-nav-menu-active");
			};
			nav_item[i].onmouseout = function(){
				hNavMenu.classList.remove("header-nav-menu-active");
			}
		})(i)
	}
}
headerNavMenu();

//分类选项卡mouseover弹出窗体
function categoryNav(){
	console.log(111)
	for(var i = 0;i<cateItem.length;i++){
		(function(i){
			cateItem[i].addEventListener("mouseover",function(){
				for(var j = 0;j<cateItem.length;j++){
					cateItem[j].classList.remove("category-item-active");
				}
				cateItem[i].classList.add("category-item-active");
			});
			cateItem[i].addEventListener("mouseout",function(){
				cateItem[i].classList.remove("category-item-active");
			});
		})(i)
	}
}
categoryNav();




/**搜索框focus**/
function searchFocus(){
	var searchText = $(".search-text")[0],
	    searchForm = $(".search-form")[0],
	    searchHot  = $(".search-hot-words")[0];
	
	searchText.onfocus = function(){
		searchForm.classList.add("search-form-focus");
		searchHot.classList.add("dis");
	}
	searchText.onblur = function(){
		searchForm.classList.remove("search-form-focus");
		searchHot.classList.remove("dis");
	}
}
searchFocus();
